package lib

import (
	"database/sql"
	"log"
)

type Queue struct {
	ID        int64          `db:"queueID"`
	Name      sql.NullString `db:"name"` //由于在mysql的users表中name没有设置为NOT NULL,所以name可能为null,在查询过程中会返回nil，如果是string类型则无法接收nil,但sql.NullString则可以接收nil值
	QueueType string         `db:queueType`
}

func FetchAllQueue() []Queue {
	rows := Dbconn.Select("select queueID,name,queueType from queue where validFlag=1 and deletedFlag=0 order by queueID")
	l := make([]Queue, 0, 0)
	for rows.Next() {
		q := new(Queue)
		e := rows.Scan(&q.ID, &q.Name, &q.QueueType)
		if e != nil {
			log.Print(e)
		}
		l = append(l, *q)
	}
	return l
}
